<template>
  <div class="shop-container">
    <div class="shop-header">
      <div class="shop-banner" style="background-image: url('https://picsum.photos/1200/300?random=1')">
        <div class="shop-header-overlay"></div>
        <div class="shop-info">
          <div class="shop-logo">
            <img :src="shop.shopLogo || 'https://picsum.photos/150/150?random=2'" alt="商家LOGO">
          </div>
          <div class="shop-details">
            <h1>{{ shop.shopName }}</h1>
            <div class="shop-rating">
              <el-rate :value="shop.rating" disabled text-color="#ff9900"></el-rate>
              <span class="rating-value">{{ shop.rating }}</span>
              <span class="monthly-sales">月售 {{ shop.monthlySales || 0 }}+</span>
            </div>
            <div class="shop-desc">
              <p>{{ shop.description }}</p>
              <p><i class="el-icon-location"></i> {{ shop.address }}</p>
              <p><i class="el-icon-phone"></i> {{ shop.phone }}</p>
            </div>
            <div class="shop-badges">
              <el-tag size="small" type="success" v-if="shop.status === 1">营业中</el-tag>
              <el-tag size="small" type="info" v-else>休息中</el-tag>
              <el-tag size="small" type="danger">起送价 ¥{{ shop.minPrice || 0 }}</el-tag>
              <el-tag size="small" type="warning">配送费 ¥{{ shop.deliveryFee || 0 }}</el-tag>
            </div>
          </div>
        </div>
      </div>
    </div>

    <div class="shop-content">
      <div class="shop-nav">
        <div class="category-nav">
          <ul>
            <li :class="{ active: activeCategory === 'all' }" @click="changeCategory('all')">全部商品</li>
            <li :class="{ active: activeCategory === 'hot' }" @click="changeCategory('hot')">热销产品</li>
            <li :class="{ active: activeCategory === 'new' }" @click="changeCategory('new')">新品上市</li>
            <li :class="{ active: activeCategory === 'discount' }" @click="changeCategory('discount')">折扣商品</li>
          </ul>
        </div>
        <div class="shop-search">
          <el-input placeholder="搜索商品" prefix-icon="el-icon-search" v-model="searchText" clearable @keyup.enter.native="onSearch">
            <el-button slot="append" icon="el-icon-search" @click="onSearch">搜索</el-button>
          </el-input>
        </div>
      </div>

      <div class="products-container">
        <h2 class="section-title">
          <span class="title-text">商品列表</span>
        </h2>
        <el-row :gutter="20" v-loading="loading">
          <el-col :xs="24" :sm="12" :md="8" :lg="6" v-for="product in filteredProducts" :key="product.id">
            <div class="product-card">
              <div class="product-image-container">
                <el-image 
                  v-if="product.image" 
                  :src="product.image" 
                  fit="cover"
                  class="product-image">
                  <div slot="error" class="image-slot">
                    <i class="el-icon-picture-outline"></i>
                  </div>
                </el-image>
                <div v-else class="image-placeholder">
                  <img :src="`https://picsum.photos/300/200?random=${product.id}`" alt="商品图片">
                </div>
                <div class="product-tags" v-if="product.tags && product.tags.length > 0">
                  <el-tag v-for="(tag, i) in product.tags" :key="i" size="mini" :type="getTagType(tag)" effect="dark">
                    {{ tag }}
                  </el-tag>
                </div>
              </div>
              <div class="product-info">
                <h3 class="product-name">{{ product.name }}</h3>
                <p class="product-desc">{{ product.description }}</p>
                <div class="product-meta">
                  <span class="product-sales">月售{{ product.sales || 0 }}+</span>
                  <span class="product-likes"><i class="el-icon-star-on"></i> {{ product.likes || 0 }}</span>
                </div>
                <div class="product-price-row">
                  <div class="product-price">¥{{ product.price.toFixed(2) }}</div>
                  <div class="product-original-price" v-if="product.originalPrice">¥{{ product.originalPrice.toFixed(2) }}</div>
                </div>
                <div class="product-actions">
                  <el-input-number 
                    v-model="product.quantity" 
                    :min="1" 
                    :max="99"
                    size="mini"
                    @change="handleQuantityChange(product)"
                  ></el-input-number>
                  <el-button type="primary" size="small" @click="addToCart(product)" icon="el-icon-shopping-cart-2">加入购物车</el-button>
                </div>
              </div>
            </div>
          </el-col>
        </el-row>
        
        <!-- 分页控件 -->
        <div class="pagination-container" v-if="pagination.total > 0">
          <el-pagination
            @size-change="handleSizeChange"
            @current-change="handleCurrentChange"
            :current-page="pagination.currentPage"
            :page-sizes="[10, 20, 50]"
            :page-size="pagination.pageSize"
            layout="total, sizes, prev, pager, next, jumper"
            :total="pagination.total">
          </el-pagination>
        </div>
        
        <div v-if="filteredProducts.length === 0 && !loading" class="empty-products">
          <i class="el-icon-goods"></i>
          <p>未找到相关商品</p>
          <el-button type="primary" @click="loadProducts">刷新试试</el-button>
        </div>
      </div>
    </div>

    <!-- 购物车抽屉 -->
    <el-drawer
      title="购物车"
      :visible.sync="cartDrawerVisible"
      direction="rtl"
      size="30%">
      <div class="cart-container">
        <div v-if="cart.length === 0" class="empty-cart">
          <i class="el-icon-shopping-cart-2"></i>
          <p>购物车是空的</p>
          <el-button type="primary" plain @click="cartDrawerVisible = false">去挑选商品</el-button>
        </div>
        <div v-else>
          <div class="cart-items">
            <div v-for="(item, index) in cart" :key="index" class="cart-item">
              <div class="item-info">
                <div class="item-name">{{ item.name }}</div>
                <div class="item-price">¥{{ item.price.toFixed(2) }} × {{ item.quantity }}</div>
              </div>
              <div class="item-actions">
                <el-input-number 
                  v-model="item.quantity" 
                  :min="1" 
                  :max="99"
                  size="mini"
                  @change="updateCartItem(index, item.quantity)"
                ></el-input-number>
                <el-button type="danger" icon="el-icon-delete" size="mini" @click="removeCartItem(index)"></el-button>
              </div>
            </div>
          </div>
          <div class="cart-footer">
            <div class="cart-total">
              <span>合计:</span>
              <span class="total-price">¥{{ cartTotal.toFixed(2) }}</span>
            </div>
            <el-button type="primary" @click="checkout">去结算</el-button>
          </div>
        </div>
      </div>
    </el-drawer>

    <!-- 悬浮购物车按钮 -->
    <div class="float-cart" @click="cartDrawerVisible = true">
      <el-badge :value="cartCount" :hidden="cartCount === 0">
        <i class="el-icon-shopping-cart-2"></i>
      </el-badge>
      <div class="cart-price" v-if="cartCount > 0">
        ¥{{ cartTotal.toFixed(2) }}
      </div>
    </div>

    <!-- 结算对话框 -->
    <el-dialog
      title="确认订单"
      :visible.sync="checkoutDialogVisible"
      width="50%">
      <div class="checkout-container">
        <h3>订单商品</h3>
        <div class="checkout-items">
          <div v-for="(item, index) in cart" :key="index" class="checkout-item">
            <span>{{ item.name }}</span>
            <span>¥{{ item.price.toFixed(2) }} × {{ item.quantity }}</span>
          </div>
        </div>
        <div class="checkout-address">
          <h3>配送地址</h3>
          <el-input v-model="order.address" placeholder="请输入配送地址"></el-input>
        </div>
        <div class="checkout-phone">
          <h3>联系电话</h3>
          <el-input v-model="order.phone" placeholder="请输入联系电话"></el-input>
        </div>
        <div class="checkout-remarks">
          <h3>订单备注</h3>
          <el-input type="textarea" v-model="order.remarks" placeholder="请输入订单备注，如配送时间等"></el-input>
        </div>
        <div class="checkout-total">
          <span>订单总计:</span>
          <span class="total-price">¥{{ cartTotal.toFixed(2) }}</span>
        </div>
      </div>
      <span slot="footer" class="dialog-footer">
        <el-button @click="checkoutDialogVisible = false">取消</el-button>
        <el-button type="primary" @click="submitOrder">提交订单</el-button>
      </span>
    </el-dialog>
  </div>
</template>

<script>
import { mapState, mapGetters } from 'vuex'
import { getShopDetail, getShopProducts } from '@/api/user'
import { createOrder } from '@/api/order'

export default {
  name: 'Shop',
  data() {
    return {
      loading: false,
      shopId: null,
      shop: {
        id: '',
        shopName: '',
        description: '',
        address: '',
        phone: '',
        rating: 0,
        businessHours: '',
        minPrice: 0,
        deliveryFee: 0
      },
      products: [],
      searchText: '',
      cartDrawerVisible: false,
      checkoutDialogVisible: false,
      order: {
        address: '',
        phone: '',
        remarks: ''
      },
      pagination: {
        currentPage: 1,
        pageSize: 10,
        total: 0
      },
      activeCategory: 'all'
    }
  },
  computed: {
    ...mapState(['cart', 'userInfo']),
    ...mapGetters(['cartCount', 'cartTotal']),
    filteredProducts() {
      if (!this.searchText) return this.products;
      
      const searchText = this.searchText.toLowerCase();
      return this.products.filter(product => 
        product.name.toLowerCase().includes(searchText) || 
        (product.description && product.description.toLowerCase().includes(searchText))
      );
    }
  },
  created() {
    this.shopId = this.$route.params.id;
    if (!this.shopId) {
      this.$router.push('/');
      return;
    }
    
    // 加载商店信息和商品
    this.loadShopData();
    this.loadProducts();
  },
  methods: {
    loadShopData() {
      this.loading = true;
      getShopDetail(this.shopId)
        .then(res => {
          if (res.code === 200) {
            this.shop = res.data;
          } else {
            this.$message.error(res.message || '获取商家信息失败');
          }
        })
        .catch(() => {
          console.error('获取商家信息失败');
          this.$message.error('获取商家信息失败');
        })
        .finally(() => {
          this.loading = false;
        });
    },
    
    loadProducts() {
      this.loading = true;
      
      let apiMethod;
      const params = {
        categoryId: undefined,
        page: this.pagination.currentPage,
        size: this.pagination.pageSize
      };
      
      // 根据选中的分类类型选择不同的API
      switch (this.activeCategory) {
        case 'hot':
          apiMethod = this.loadHotProducts;
          break;
        case 'new':
          apiMethod = this.loadNewProducts;
          break;
        case 'discount':
          apiMethod = this.loadDiscountProducts;
          break;
        default:
          apiMethod = this.loadAllProducts;
      }
      
      apiMethod(params)
        .catch(() => {
          console.error('获取商品列表失败');
          this.$message.error('获取商品列表失败');
          this.products = [];
        })
        .finally(() => {
          this.loading = false;
        });
    },
    
    // 搜索商品
    onSearch() {
      this.pagination.currentPage = 1;
      this.loadProducts();
    },
    
    // 处理页码变化
    handleCurrentChange(page) {
      this.pagination.currentPage = page;
      this.loadProducts();
    },
    
    // 处理每页条数变化
    handleSizeChange(size) {
      this.pagination.pageSize = size;
      this.pagination.currentPage = 1;
      this.loadProducts();
    },
    
    handleQuantityChange(product) {
      // 更新商品数量
      console.log('数量改变:', product.name, product.quantity)
    },
    
    addToCart(product) {
      // 检查是否登录
      if (!this.$store.getters.isLogin) {
        this.$message.warning('请先登录')
        this.$router.push('/login?redirect=' + this.$route.fullPath)
        return
      }
      
      // 创建购物车项
      const cartItem = {
        id: product.id,
        merchantId: product.merchantId,
        name: product.name,
        price: product.price,
        quantity: product.quantity || 1
      }
      
      // 添加到购物车
      this.$store.dispatch('addToCart', cartItem)
      this.$message.success('已加入购物车')
      
      // 重置商品数量
      product.quantity = 1
      
      // 显示购物车
      this.cartDrawerVisible = true
    },
    
    updateCartItem(index, quantity) {
      this.$store.commit('updateCartItem', { index, quantity })
    },
    
    removeCartItem(index) {
      this.$store.commit('removeCartItem', index)
    },
    
    checkout() {
      if (this.cart.length === 0) {
        this.$message.warning('购物车为空')
        return
      }
      
      // 填充用户信息
      if (this.userInfo) {
        this.order.address = this.userInfo.address || ''
        this.order.phone = this.userInfo.phone || ''
      }
      
      this.checkoutDialogVisible = true
    },
    
    submitOrder() {
      if (!this.order.address) {
        this.$message.warning('请填写配送地址')
        return
      }
      
      if (!this.order.phone) {
        this.$message.warning('请填写联系电话')
        return
      }
      
      // 准备订单数据
      const orderData = {
        userId: this.userInfo.id,
        merchantId: this.shopId,
        address: this.order.address,
        phone: this.order.phone,
        remarks: this.order.remarks,
        totalAmount: this.cartTotal,
        deliveryFee: this.shop.deliveryFee || 0,
        payAmount: this.cartTotal + (this.shop.deliveryFee || 0),
        payType: 1, // 默认支付方式: 1-微信
        // 序列化商品数据
        items: JSON.stringify(this.cart.map(item => ({
          productId: item.id,
          name: item.name,
          price: item.price,
          quantity: item.quantity
        }))),
        // 默认为系统派单
        deliveryMode: 1
      }
      
      // 设置加载状态
      this.loading = true
      
      // 调用API创建订单
      createOrder(orderData)
        .then(res => {
          if (res.code === 200) {
            this.$message.success('订单提交成功')
            // 清空购物车
            this.$store.commit('clearCart')
            this.checkoutDialogVisible = false
            this.cartDrawerVisible = false
            
            // 跳转到订单页面
            this.$router.push('/order')
          } else {
            this.$message.error(res.message || '订单提交失败')
          }
        })
        .catch(() => {
          console.error('提交订单失败');
          this.$message.error('订单提交失败，请稍后重试');
        })
        .finally(() => {
          this.loading = false
        })
    },
    
    changeCategory(category) {
      this.activeCategory = category;
      this.pagination.currentPage = 1;
      this.searchText = '';
      this.loadProducts();
    },
    
    loadHotProducts(params) {
      return this.$http.get(`/api/user/product/hot?merchantId=${this.shopId}`, { params })
        .then(res => {
          const { data } = res;
          if (data.code === 200) {
            this.handleProductResponse(data.data, '热销');
          } else {
            this.$message.error(data.message || '获取热销商品失败');
            this.products = [];
          }
        })
        .catch(() => {
          console.log('热销商品API不可用，使用普通商品API替代');
          // 如果热销商品API不可用，使用普通商品API替代
          return this.loadAllProducts({
            ...params,
            // 添加排序参数，按销量排序
            sortField: 'sales',
            sortOrder: 'desc'
          }, '热销');
        });
    },
    
    loadNewProducts(params) {
      return this.$http.get(`/api/user/product/new?merchantId=${this.shopId}`, { params })
        .then(res => {
          const { data } = res;
          if (data.code === 200) {
            this.handleProductResponse(data.data, '新品');
          } else {
            this.$message.error(data.message || '获取新品上市失败');
            this.products = [];
          }
        })
        .catch(() => {
          console.log('新品上市API不可用，使用普通商品API替代');
          // 如果新品API不可用，使用普通商品API替代
          return this.loadAllProducts({
            ...params,
            // 添加排序参数，按创建时间排序
            sortField: 'createTime',
            sortOrder: 'desc'
          }, '新品');
        });
    },
    
    loadDiscountProducts(params) {
      return this.$http.get(`/api/user/product/discount?merchantId=${this.shopId}`, { params })
        .then(res => {
          const { data } = res;
          if (data.code === 200) {
            this.handleProductResponse(data.data, '折扣');
          } else {
            this.$message.error(data.message || '获取折扣商品失败');
            this.products = [];
          }
        })
        .catch(() => {
          console.log('折扣商品API不可用，使用普通商品API替代');
          // 如果折扣商品API不可用，使用普通商品API替代
          return this.loadAllProducts({
            ...params,
            // 过滤有折扣的商品
            hasDiscount: true
          }, '折扣');
        });
    },
    
    loadAllProducts(params, tagType) {
      params.keyword = this.searchText || undefined;
      
      return getShopProducts(this.shopId, params)
        .then(res => {
          if (res.code === 200) {
            this.handleProductResponse(res.data, tagType);
          } else {
            this.$message.error(res.message || '获取商品列表失败');
            this.products = [];
          }
        });
    },
    
    handleProductResponse(productData, tagType) {
      console.log('获取到的商品数据:', productData);
      
      // 检查list是否存在且是数组
      if (productData && Array.isArray(productData.records)) {
        this.products = productData.records.map(item => {
          // 添加标签
          let tags = item.tags || [];
          if (tagType && !tags.includes(tagType)) {
            tags = [...tags, tagType];
          }
          
          return {
            ...item,
            quantity: 1, // 添加购物车数量属性
            tags: tags  // 设置标签
          };
        });
        this.pagination.total = productData.total || 0;
      } else if (productData && Array.isArray(productData.list)) {
        // 后端可能使用list作为列表字段名
        this.products = productData.list.map(item => {
          // 添加标签
          let tags = item.tags || [];
          if (tagType && !tags.includes(tagType)) {
            tags = [...tags, tagType];
          }
          
          return {
            ...item,
            quantity: 1, // 添加购物车数量属性
            tags: tags  // 设置标签
          };
        });
        this.pagination.total = productData.total || 0;
      } else {
        console.error('商品数据格式异常:', productData);
        this.products = [];
        this.pagination.total = 0;
      }
      
      // 确保this.products是响应式的
      if (this.products.length > 0) {
        console.log('处理后的商品数据:', this.products);
        // 强制刷新一下数据
        this.$nextTick(() => {
          this.$forceUpdate();
        });
      }
    },
    
    getTagType(tag) {
      if (tag.includes('折扣')) {
        return 'danger';
      } else if (tag === '热销') {
        return 'warning';
      } else if (tag === '新品') {
        return 'success';
      } else if (tag === '折扣') {
        return 'danger';  
      }
      return '';
    }
  }
}
</script>

<style scoped>
.shop-container {
  min-height: 100vh;
  background-color: #f5f5f5;
}

.shop-header {
  margin-bottom: 20px;
}

.shop-banner {
  height: 300px;
  background-size: cover;
  background-position: center;
  position: relative;
  border-radius: 0 0 8px 8px;
  overflow: hidden;
}

.shop-header-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(to bottom, rgba(0,0,0,0.1), rgba(0,0,0,0.7));
}

.shop-info {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  padding: 30px;
  color: white;
  display: flex;
  align-items: flex-end;
}

.shop-logo {
  width: 100px;
  height: 100px;
  margin-right: 20px;
  border-radius: 8px;
  overflow: hidden;
  border: 3px solid white;
  box-shadow: 0 4px 10px rgba(0,0,0,0.2);
  flex-shrink: 0;
}

.shop-logo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.shop-details {
  flex: 1;
}

.shop-details h1 {
  margin: 0 0 10px 0;
  font-size: 28px;
  text-shadow: 1px 1px 3px rgba(0,0,0,0.5);
}

.shop-rating {
  display: flex;
  align-items: center;
  margin-bottom: 10px;
}

.rating-value {
  margin-left: 5px;
  font-weight: bold;
  color: #ffcc00;
}

.monthly-sales {
  margin-left: 15px;
  font-size: 14px;
  opacity: 0.9;
}

.shop-desc {
  font-size: 14px;
  opacity: 0.9;
  margin-bottom: 10px;
}

.shop-desc p {
  margin: 5px 0;
}

.shop-badges {
  display: flex;
  gap: 10px;
}

.shop-content {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 20px;
}

.shop-nav {
  display: flex;
  justify-content: space-between;
  margin-bottom: 20px;
  background-color: white;
  border-radius: 8px;
  padding: 10px 20px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

.category-nav {
  flex: 1;
}

.category-nav ul {
  display: flex;
  list-style: none;
  padding: 0;
  margin: 0;
}

.category-nav li {
  padding: 10px 20px;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all 0.3s;
  font-weight: bold;
}

.category-nav li:hover {
  color: #ff6000;
}

.category-nav li.active {
  color: #ff6000;
  border-bottom-color: #ff6000;
}

.shop-search {
  width: 250px;
}

.section-title {
  font-size: 20px;
  margin-bottom: 20px;
  position: relative;
  padding-left: 12px;
}

.title-text::before {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 4px;
  height: 20px;
  background-color: #ff6000;
  border-radius: 2px;
}

.products-container {
  margin-bottom: 50px;
}

.product-card {
  background-color: white;
  border-radius: 8px;
  overflow: hidden;
  margin-bottom: 20px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.05);
  transition: all 0.3s;
  height: 100%;
  display: flex;
  flex-direction: column;
  border: 1px solid #f0f0f0;
}

.product-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 8px 20px rgba(0,0,0,0.1);
  border-color: #ffe0cc;
}

.product-image-container {
  position: relative;
  height: 200px;
  overflow: hidden;
}

.product-image-container img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.5s;
}

.product-card:hover .product-image-container img {
  transform: scale(1.05);
}

.image-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: #f5f5f5;
  color: #999;
  font-size: 24px;
}

.product-tags {
  position: absolute;
  top: 10px;
  left: 10px;
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  z-index: 2;
}

.product-tags .el-tag {
  border-radius: 4px;
  font-weight: bold;
  padding: 2px 6px;
}

.product-info {
  padding: 15px;
  flex: 1;
  display: flex;
  flex-direction: column;
}

.product-name {
  margin: 0 0 8px 0;
  font-size: 18px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.product-desc {
  margin: 0 0 10px 0;
  color: #666;
  font-size: 14px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
  height: 40px;
}

.product-meta {
  display: flex;
  justify-content: space-between;
  margin-bottom: 10px;
  font-size: 12px;
  color: #999;
}

.product-likes i {
  color: #ff9900;
}

.product-price-row {
  display: flex;
  align-items: center;
  margin-bottom: 15px;
}

.product-price {
  color: #ff6000;
  font-size: 20px;
  font-weight: bold;
  margin-right: 10px;
}

.product-original-price {
  color: #999;
  font-size: 14px;
  text-decoration: line-through;
}

.product-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: auto;
}

.empty-products {
  padding: 60px 0;
  text-align: center;
  color: #999;
}

.empty-products i {
  font-size: 50px;
  margin-bottom: 15px;
  color: #ddd;
}

.cart-container {
  padding: 15px;
  height: 100%;
  display: flex;
  flex-direction: column;
}

.empty-cart {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  color: #999;
}

.empty-cart i {
  font-size: 50px;
  margin-bottom: 15px;
  color: #ddd;
}

.empty-cart p {
  margin-bottom: 20px;
}

.cart-items {
  flex: 1;
  overflow-y: auto;
}

.cart-item {
  display: flex;
  justify-content: space-between;
  padding: 15px 0;
  border-bottom: 1px solid #f0f0f0;
}

.item-info {
  flex: 1;
}

.item-name {
  font-weight: bold;
  margin-bottom: 5px;
}

.item-price {
  color: #666;
  font-size: 14px;
}

.item-actions {
  display: flex;
  align-items: center;
}

.item-actions .el-button {
  margin-left: 10px;
}

.cart-footer {
  margin-top: 20px;
  padding-top: 15px;
  border-top: 1px solid #f0f0f0;
}

.cart-total {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 15px;
  font-size: 16px;
}

.total-price {
  color: #ff6000;
  font-size: 20px;
  font-weight: bold;
}

.cart-footer .el-button {
  width: 100%;
}

.float-cart {
  position: fixed;
  right: 30px;
  bottom: 30px;
  width: 60px;
  height: 60px;
  background-color: #ff6000;
  color: white;
  border-radius: 50%;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  cursor: pointer;
  box-shadow: 0 4px 10px rgba(255, 96, 0, 0.3);
  transition: all 0.3s;
  z-index: 100;
}

.float-cart:hover {
  transform: scale(1.1);
}

.float-cart i {
  font-size: 24px;
}

.cart-price {
  font-size: 12px;
  margin-top: 3px;
}

.checkout-container {
  padding: 0 20px;
}

.checkout-container h3 {
  margin: 20px 0 10px 0;
  font-size: 16px;
}

.checkout-items {
  background-color: #f9f9f9;
  padding: 15px;
  border-radius: 4px;
  margin-bottom: 20px;
}

.checkout-item {
  display: flex;
  justify-content: space-between;
  padding: 5px 0;
  font-size: 14px;
}

.checkout-address, .checkout-phone, .checkout-remarks {
  margin-bottom: 20px;
}

.checkout-total {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: 20px 0;
  font-size: 16px;
}

.pagination-container {
  margin-top: 30px;
  padding-top: 20px;
  border-top: 1px solid #eee;
  display: flex;
  justify-content: center;
}

@media (max-width: 768px) {
  .shop-banner {
    height: 220px;
  }
  
  .shop-logo {
    width: 80px;
    height: 80px;
  }
  
  .shop-details h1 {
    font-size: 24px;
  }
  
  .shop-nav {
    flex-direction: column;
  }
  
  .shop-search {
    width: 100%;
    margin-top: 10px;
  }
  
  .category-nav ul {
    overflow-x: auto;
    white-space: nowrap;
    padding-bottom: 5px;
  }
  
  .float-cart {
    width: 50px;
    height: 50px;
    right: 20px;
    bottom: 20px;
  }
}
</style> 